package com.wswy.wzcx.ui.njdb

import android.content.Context
import android.text.TextUtils
import com.wswy.wzcx.utils.FileUtils
import java.io.File

object NjdbUtils {


    private val KEYS = arrayOf("P","Q","Z1")

    fun getImgFiles(context: Context,userCarId:Int):Map<String,File>{

        val retMap = HashMap<String,File>()
        FileUtils.listFiles(context, "njdb/${userCarId}/")?.forEach {

            val key = it?.name?.removePrefix("img_njdb_")?.removeSuffix(".jpg")

            val idx = KEYS.indexOfFirst { TextUtils.equals(key,it) }
            if (idx != -1 && key != null && it.exists()){
                retMap[key] = it
            }
        }

        return retMap
    }


    fun deleteDir(context: Context,userCarId:Int){
        FileUtils.deleteDir(context,"njdb/${userCarId}/")
    }

}